# -*- coding: utf-8 -*-
from django.db import models
from django.contrib.auth.models import User

# Create your models here.

class ScheduleType(models.Model):
    id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=20)
    
    class Meta:
        db_table="SCHEDULE_TYPE"
        
    def __unicode__(self):
        return self.name

class Schedule(models.Model):
    id = models.AutoField(primary_key=True)
    title = models.CharField(max_length=100)
    keyword = models.CharField(max_length=30)
    start_date = models.DateField()
    end_date = models.DateField()
    schedule_type = models.ForeignKey(ScheduleType)
    content = models.CharField(max_length=4000,null=True)
    target = models.CharField(max_length=2000,null=True)
    status = models.SmallIntegerField(default=0)
    commit_date = models.DateTimeField(null=True)
    created_date = models.DateTimeField(auto_now_add=True)
    created_by = models.ForeignKey(User)
    review = models.CharField(max_length=2000)
    review_finish_date=models.DateTimeField(null=True)
    
    class Meta:
        db_table="SCHEDULE"
        
    def __unicode__(self):
        return self.id
#    def save(self):
#        if self.created_by == None:
#            self.created_by = 1
#        super(Schedule,self).save()

class TodoListSchedule(models.Model):
    id = models.AutoField(primary_key=True)
    auth_user = models.ForeignKey(User)
    schedule_type = models.ForeignKey(ScheduleType)
    start_date = models.DateField()
    end_date = models.DateField()
    
    class Meta:
        db_table = "TODO_LIST_SCHEDULE"
        